package optimization.ifelse.strategy;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ManagerStrategy {

    public static void excuteStrategy(String type){
        String clz=StrategySingleton.getInstance().strategy(type);
        try {
            /*
            * 通过反射将RefelDbTypeEnum中映射的类实例化
            * */
            Class clazz=Class.forName(clz);
            Method excute =clazz.getDeclaredMethod("excute");
            excute.invoke(clazz.newInstance());
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }

}
